

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/scholership")
public class scholership extends HttpServlet {
	private static final long serialVersionUID = 1L;
  public scholership() throws ClassNotFoundException {
        super();
        Class.forName ("org.sqlite.JDBC");
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		try {
			Connection conn = DriverManager.getConnection("jdbc:sqlite:cms.db");
			String name="bcsf11a001";
			PreparedStatement preStatement = conn.prepareStatement("select name,amount,due,paid from scholership where roll= ?");
		    String s="<table  cellspacing=\"1\" cellpadding=\"5\" border=\"1\" style=\"width:100%;\"><tbody><tr class=\"gvHeader\" align=\"center\" valign=\"middle\"><th valign=\"top\" scope=\"col\">Name</th><th valign=\"top\" scope=\"col\">Amount</th><th valign=\"top\" scope=\"col\">Due Date</th><th valign=\"top\" scope=\"col\">Paid Date</th></tr>";
		    preStatement.setString(1, name);
		    ResultSet res=preStatement.executeQuery();
		     while(res.next())
		   {
		    String nam=res.getString(1);
		    String amount=res.getString(2);
		    String due=res.getString(3);
		    String paid=res.getString(4);
		     s=s+ "<tr><td>"+ nam +"</td><td>"+amount+"</td><td>"+due+"</td><td>"+paid+"</td><tr>";
		   }
		     s=s+"</tbody></table>";
		    response.getWriter().println(s);
		    preStatement.close();
			conn.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}


	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

}
